<template>
	<view class="item">
		<image class="item-img" :src="item.spuImg"
		 mode="aspectFill"></image>
		<view class="item-right">
			<view class="item-title">{{item.spuTitle}}</view>
			<view class="item-price">
				<text>折扣价</text>
				<text>￥</text>
				<text>{{item.spuPrice /100}}</text>
				<text>￥{{item.spuOriginalPrice/100}}</text>
			</view>
			<view class="item-bottom">
				<view class="zekou">
					{{item | zekou}}折
				</view>
				<image class="cart" src="../../static/card.png" mode="widthFix" @click="jiarugwBtn(item)"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import mixi from '../data/index.js'
	export default {
		props: {
			item: {
				type: Object,
				default: () => {}
			}
		},
		mixins:[mixi],
		filters: {
			zekou(item) {
				return ((item.spuPrice / item.spuOriginalPrice) * 10).toFixed(1);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item {
		background-color: #F7F7F7;
		padding: 10rpx 18rpx;
		border-radius: 20rpx;
		display: flex;
		color: #000000;
		align-items: center;

		&-img {
			height: 215rpx;
			width: 215rpx;
			border-radius: 20rpx;
		}

		&-right {
			flex: 1;
			padding: 15rpx 20rpx;

			.item-title {
				width: 400rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				-o-text-overflow: ellipsis;
				font-size: 16px;
			}

			.item-price {
				margin-top: 10rpx;
				color: #E04C20;

				text {
					&:first-child {
						font-size: 12px;
					}

					&:nth-child(2) {
						font-size: 10px;
						margin-left: 14rpx;
					}

					&:nth-child(3) {
						font-size: 25px;
						font-weight: bold;
					}

					&:last-child {
						color: #999999;
						text-decoration: line-through;
						font-size: 12px;
						margin-left: 8rpx;
					}
				}
			}
		}

		&-bottom {
			display: flex;
			justify-content: space-between;
			align-items: flex-end;
			margin-top: 20rpx;

			.zekou {
				background-color: #36B542;
				color: #FFFFFF;
				padding: 10rpx 40rpx;
				border-radius: 50rpx;
				font-size: 11px;
			}

			.cart {
				width: 60rpx;
			}
		}
	}
</style>
